<?php
class Authorization {
	public function check($params) {
		require_once('acl.php');
		$baseURL = $GLOBALS['CFG']->config['base_url'];
		$routing =& load_class('Router');
		$class = $routing->fetch_class();
		$method = $routing->fetch_method();
		// Session variables extracted from cookies
		if (isset($_COOKIE) && isset($_COOKIE['ci_session'])) {
			$ci_session = unserialize($_COOKIE['ci_session']);
			if (!empty($ci_session['logged_in'])) {
				$session = $ci_session['logged_in'];
			}
		}
		// The page is available to all
		if (!empty($allowAll[$class][$method])) {
			return True;
		} 
		// The session is not initiated and the group is not set
		if (!isset($session) || !isset($session['group'])) {
			header("location: {$baseURL}index.php/session/login");
			exit;
		}
		// The session is initiated, but the user has no access
		if (empty($allowOnly[$session['group']][$class][$method])
		||
		$allowOnly[$session['group']][$class][$method] != True) {
			header("location: {$baseURL}index.php/common/unauthorized");
			exit;
		}
		// If we get here, authorization is succeed!
		return True;
	}
}
?>